{% load i18n avatar_tags %}
{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{% block title %}{{ SITE_NAME }}{% endblock %}</title>
    {% block head %}
      {% if DEBUG_STATIC %}
      <link href="{% static "lib/css/jquery.dataTables.css" %}" rel="stylesheet" />
      <link href="{% static "lib/css/select2.css" %}" rel="stylesheet"/>
      <link href="{% static "lib/css/bootstrap.css" %}" rel="stylesheet"/>
      <link href="{% static "lib/css/jquery-ui.theme.css" %}" rel="stylesheet"/>
      <link href="{% static "lib/css/jquery-ui.structure.css" %}" rel="stylesheet"/>
      <link href="{% static "lib/css/bootstrap-datetimepicker.css" %}" rel="stylesheet" />
      {% else %}
      <link href="{% static "lib/css/assets.min.css" %}" rel="stylesheet"/>
      {% endif %}
      <link href="{% static "geonode/css/base.css" %}" rel="stylesheet" />
      <style type="text/css">[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}</style>
      {% block extra_head %}
      {% endblock %}
    {% endblock %}
    <!--[if IE]>
      <script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
      <style>
        #ieflag{
            display: block !important;
            height: 150px;
            text-align: center;
        }
      </style>
    <![endif]-->
  </head>

  <body class="{% block body_class %}{% endblock %}">

    {% block header %}
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
            <span class="sr-only">{% trans "Toggle navigation" %}</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="{% url "home" %}">GeoNode</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            {% block tabs %}
            <li id="nav_layers">
              <a href="{% url "layer_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Layers" %}</a>
            </li>
            <li id="nav_maps">
              <a href="{% url "maps_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Maps" %}</a>
            </li>
            <li id="nav_documents">
              <a href="{% url "document_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Documents" %}</a>
            </li>
            {% if GEONODE_APPS_ENABLE and GEONODE_APPS_NAV_MENU_ENABLE %}
            <li id="nav_maps">
              <a href="{% url "apps_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% blocktrans %}{{GEONODE_APPS_NAME}}{% endblocktrans %}</a>
            </li>
            {% endif %}
           {% block extra_tab %}
           {% endblock %}
            <li id="nav_people">
              <a href="{% url "profile_browse" %}">{% trans "People" %}</a>
            </li>
            <li id="nav_groups">
              <a href="{% url "group_list" %}">{% trans "Groups" %}</a>
            </li>
            {% endblock %}
          </ul>
          <form class="navbar-form" id="search" action="{% url "search" %}" >
            <div class="col-md-3">
              <div class="input-group">
                <div id="search-container" class="autocomplete-input">
                    {% if HAYSTACK_SEARCH %}
                    <input autocomplete="off" id="search_input" type="text" placeholder="{% trans 'Search' %}" name="q">
                    {% else %}
                    <input autocomplete="off" type="text" name="title__icontains" id="search_input" placeholder="{% trans 'Search' %}" >
                    {% endif %}
                </div>
                <span class="input-group-btn">
                  <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i></button>
                </span>
              </div>
            </div>
          </form>
          <ul class="nav navbar-nav navbar-right">
            {% if not user.is_authenticated and ACCOUNT_OPEN_SIGNUP %}
            <li><a href="{% url "account_signup" %}">{% trans "Register" %}</a></li>
            {% endif %}
            {% if user.is_authenticated %}
            <li>
              <a href="#" data-toggle="modal" data-target="#UserModal" role="button" aria-expanded="false">
                {% autoescape off %}{% avatar user 40 %} {{ user.username }}{% endautoescape %}
              </a>
            </li>
            {% else %}
            <li>
              <a href="#" data-toggle="modal" data-target="#SigninModal" role="button" >
                {% trans "Sign in" %}
              </a>
            </li>
            {% endif %}
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>
    {% endblock header %}

    <div class="alert alert-danger alert-dismissible" role="alert" id="ieflag" style="display:none">
      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h1>{% trans "You are using an outdated browser that is not supported by GeoNode." %}</h1>
      <p>{% trans "Please use a <strong>modern browser</strong> like Mozilla Firefox, Google Chrome or Safari." %}</p>
    </div>

  <div id="wrap">
    {% block middle %}
    <div class="container">
      {% include "_status_message.html" %}
      {% include "_announcements.html" %}
      {% include "_messages.html" %}
      {% block body_outer %}
      <div class="row">
        <div class="col-md-8">
        {% block body %}
        <div id="description">
              <h3>{% trans "There was a problem loading this page" %}</h3>
            </div>
            {% blocktrans %}
            Please contact your GeoNode administrator (they may have received an email automatically if they configured it properly).
            If you are the site administrator, enable debug mode to see the actual error and fix it or file an issue in <a href="http://github.com/GeoNode/geonode/issues">GeoNode's issue tracker</a>
            {% endblocktrans %}
        {% endblock %}
        </div>
        <div class="col-md-4">
        {% block sidebar %}{% endblock %}
        </div>
      </div>
      {% endblock %}
    </div>
    {% endblock middle %}
  </div>

  {% block footer %}
  <footer>
    <div class="container">
      <div class="row">
        <div class="col-md-2">
          <ul class="list-unstyled">
            <li>{% trans "Data" %}</li>
            <li><a href="{% url "layer_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Layers" %}</a></li>
            <li><a href="{% url "document_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Documents" %}</a></li>
            <li><a href="{% url "services" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Remote Services" %}</a></li>
            {% if user.is_authenticated and not READ_ONLY_MODE %}
                <li role="separator" class="divider"></li>
                <li><a href="{% url "layer_upload" %}">{% trans "Upload Layer" %}</a></li>
                {% if USE_GEOSERVER and CREATE_LAYER %}
                  <li><a href="{% url "layer_create" %}">{% trans "Create a new layer" %}</a></li>
                {% endif %}
                <li><a href="{% url "document_upload" %}">{% trans "Upload Document" %}</a></li>
            {% endif %}
            {% if user.is_superuser or user.is_staff %}
              {% if not READ_ONLY_MODE %}
                <li><a href="{% url "register_service" %}">{% trans "Add Remote Service" %}</a></li>
              {% endif %}
            {% endif %}
          </ul>
        </div>
        <div class="col-md-2">
          <ul class="list-unstyled">
            <li>{% trans "Maps" %}</li>
            <li><a href="{% url "maps_browse" %}?limit={{ CLIENT_RESULTS_LIMIT }}">{% trans "Explore Maps" %}</a></li>
            {% if user.is_authenticated and not READ_ONLY_MODE %}
            <li> <a href="{% url "new_map" %}">{% trans "Create Map" %}</a></li>
            {% endif %}
          </ul>
        </div>
      <div class="col-md-2">
          <ul class="list-unstyled">
            <li>{% trans "About" %}</li>
            <li><a href="{% url "profile_browse" %}">{% trans "People" %}</a></li>
            <li><a href="{% url "group_list" %}">{% trans "Groups" %}</a></li>
            {% if perms.announcements.can_manage %}
            <li><a href="{% url "announcements_list" %}">{% trans "Announcements" %}</a></li>
            {% endif %}
            {% if not READ_ONLY_MODE %}
              <li><a href="{% url "geonode.invitations:geonode-send-invite" %}">{% trans "Invite Users" %}</a></li>
            {% endif %}
            {% if user.is_superuser and not READ_ONLY_MODE %}
              <li><a href="/admin/people/profile/add/">{% trans "Add User" %}</a></li>
              <li><a href="{% url "group_create" %}">{% trans "Create Group" %}</a></li>
            {% endif %}
          </ul>
        </div>

        <div class="col-md-6 text-right">
          {% block contactus %}
          {% endblock contactus %}
          <ul class="list-unstyled">
            <li>{% trans "Powered by" %} <a href="http://geonode.org">{% trans "GeoNode" %}</a>{% if user.is_staff %} <em>{% trans "version" %} {{ VERSION }}</em>{% endif %}</li>
            <li><a href="{% url "developer" %}">{% trans "Developers" %}</a> | <a href="{% url "about" %}">{% trans "About" %}</a><li>
          </ul>
          <label class="hidden">{% trans "Language" %}</label>
          {% if csrf_token != "NOTPROVIDED" %}
          {% get_current_language as LANGUAGE %}
          <form class="form-inline" action="/i18n/setlang/" method="post">
          {% csrf_token %}
            <select class="col-md-6 pull-right" name="language" onchange="javascript:form.submit()">
              {% for lang in LANGUAGES %}
              <option value="{{ lang.0 }}" {% ifequal LANGUAGE_CODE lang.0 %} selected="selected"{% endifequal %}>
                {{ lang.1 }}
              </option>
              {% endfor %}
            </select>
          </form>
          {% endif %}
        </div>
      </div>
    </div>
  </footer>
  {% endblock footer %}


    <!-- Modal must stay outside the navbar -->
    {% if not user.is_authenticated %}
    <div class="modal fade" id="SigninModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">{% trans "Close" %}</span></button>
            <h4 class="modal-title" id="myModalLabel">{% trans "Sign in" %}</h4>
          </div>
          <form class="form-signin" role="form" action="{% url "account_login" %}?next={{ request.path }}" method="post">
            <div class="modal-body">
              {% csrf_token %}
              <div class="form-group">
                <label for="id_username" class="sr-only">{% trans "Username" %}:</label>
                <input id="id_username" class="form-control" name="username" placeholder="{% trans "Username" %}" type="text" />
              </div>
              <div class="form-group">
                <label for="id_password" class="sr-only">{% trans "Password" %}:</label>
                <input id="id_password" class="form-control" name="password" placeholder="Password" type="password" autocomplete="off" />
              </div>
              <label class="checkbox">
                <input type="checkbox" /> {% trans "Remember Me" %}
              </label>
            </div>
            <div class="modal-footer">
              <button type="submit" class="btn btn-primary btn-block">{% trans "Sign in" %}</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    {% else %}
    <div class="modal fade" id="UserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">{% trans "Menu" %}</h4>
          </div>
          <div class="modal-body">
            <ul class="list-unstyled">
              <li><a href="{% url "layer_upload" %}"><i class="fa fa-cloud-upload"></i> {% trans "Upload Layers" %}</a></li>
              <li class="modal-divider"></li>
              <li><a href="{{ user.get_absolute_url }}"><i class="fa fa-user"></i> {% trans "Profile" %}</a></li>
              <li><a href="{% url "recent-activity" %}"><i class="fa fa-fire"></i> {% trans "Recent Activity" %}</a></li>
              <li><a href="{% url "messages_inbox" %}"><i class="fa fa-inbox"></i> {% trans "Inbox" %}</a></li>
              {% if USE_NOTIFICATIONS %}
                <li><a href="{% url "pinax_notifications:notice_settings" %}"><i class="fa fa-bell"></i> {% trans "Notifications" %}</a></li>
              {% endif %}
              {% if perms.announcements.can_manage %}
              <li><a href="{% url "announcements_list" %}"><i class="fa fa-bullhorn"></i> {% trans "Announcements" %}</a></li>
              {% endif %}
              {% if not READ_ONLY_MODE %}
                <li><a href="{% url "geonode.invitations:geonode-send-invite" %}"><i class="fa fa-edit"></i> {% trans "Invite Users" %}</a></li>
              {% endif %}
              <li class="modal-divider"></li>
              {% if user.is_superuser or user.is_staff %}
                <li><a href="{% url "proxy" %}?url={{ OGC_SERVER.default.LOCATION }}"><i class="fa fa-gears"></i> {% trans "GeoServer" %}</a></li>
                <li><a href="{% url "admin:index" %}"><i class="fa fa-cog"></i> {% trans "Admin" %}</a></li>
              {% endif %}
              {% block extra_user_menu %}
              {% endblock %}
              <li class="modal-divider"></li>
              <li><a title="{% trans "Help" %}" rel="tooltip" href="/help/"><i class="fa fa-question-circle"></i> {% trans "Help" %}</a></li>
            </ul>
          </div>
          <div class="modal-footer">
            <form action="{% url "account_logout" %}" id="logout_form" method="post">
              {% csrf_token %}
              <a class="btn btn-warning btn-block" href="javascript:{}" onclick="document.getElementById('logout_form').submit();">{% trans "Log out" %}</a>
            </form>
          </div>
        </div>
      </div>
    </div>
    {% endif %}
    <!-- End of Modal -->

    {% if DEBUG_STATIC %}
    <script src="{% static "lib/js/jquery.min.js" %}"></script>
    <script src="{% static "lib/js/jquery.dataTables.js" %}"></script>
    <script src="{% static "lib/js/jquery.timeago.js" %}"></script>
    <script src="{% static "lib/js/jquery.ajaxprogress.js" %}"></script>
    <script src="{% static "lib/js/jquery-ui.custom.js" %}"></script>
    <script src="{% static "lib/js/jquery.raty.js" %}"></script>
    <script src="{% static "lib/js/bootstrap.min.js" %}"></script>
    <script src="{% static "lib/js/json2.js" %}"></script>
    <script src="{% static "lib/js/select2.js" %}"></script>
    <script src="{% static "lib/js/waypoints.js" %}"></script>
    {% else %}
    <script src="{% static "lib/js/assets.min.js" %}"></script>
    {% endif %}
    <script src="{% static "geonode/js/utils/utils.js" %}"></script>
    <script src="{% static "geonode/js/base/base.js" %}"></script>
    <script type="text/javascript" src="{% url "javascript-catalog" %}"></script>
    {% block extra_script %}{% endblock extra_script %}
  </body>
</html>
